package jp.co.showbiz.admin.member.imp;

import java.util.HashMap;
import java.util.List;

import jp.co.showbiz.admin.member.dao.MemberDao;
import jp.co.showbiz.common.base.BaseImplement;
import jp.co.showbiz.common.util.CommUtil;

/**
 * クラス概要<br>
 * クラス説明<br>
 * 
 * 
 * @author $Author: $
 * @version $Revision: 1.1 $
 */
public class MemberImpl extends BaseImplement {
	/**
     * 
     */
	MemberDTO memberDTO;

	public MemberDTO getMemberDTO() {
		return memberDTO;
	}

	public void setMemberDTO(MemberDTO memberDTO) {
		this.memberDTO = memberDTO;
	}

	/**
	 * this is
	 * 
	 * @throws Exception
	 *             e
	 * @version 1.0
	 */
	public MemberImpl() throws Exception {
		super();
	}

    public boolean user_list(MemberDTO dto, int curPage) throws Exception {
    	dto.setUqUserRankId(rankNameChange(dto.getUqUserRank()));
		MemberDao dao = new MemberDao();
		int total = dao.getUserTotalCount(dto);
		HashMap<String, Integer> pageMap = CommUtil.getPageInfo(curPage, total, 10, 10);
		int skip = pageMap.get("skip");
		List<HashMap<String, Object>> queryResult = dao.getUserList(dto, skip, 10);
		dto.setListUser(queryResult);
		dto.setPageMap(pageMap);
		return true;
	}
	
    @SuppressWarnings("unchecked")
	public boolean user_query(MemberDTO dto) throws Exception {
		MemberDao dao = new MemberDao();
		HashMap<String, Object> map = (HashMap<String, Object>) dao.getUserQuery(dto);
		dto.setMemInfo(map);
		return true;
	}

    public boolean favorite_list(MemberDTO dto, int curPage) throws Exception {
		MemberDao dao = new MemberDao();
		int total = dao.getFavoriteTotalCount(dto);
		HashMap<String, Integer> pageMap = CommUtil.getPageInfo(curPage, total, 10, 10);
		int skip = pageMap.get("skip");
		List<HashMap<String, Object>> queryResult = dao.getFavoriteList(dto, skip,10);
		dto.setListKiniIri(queryResult);
		dto.setPageMap(pageMap);
		return true;
	}
    
    @SuppressWarnings("unchecked")
    public boolean point_query(MemberDTO dto) throws Exception {
		MemberDao dao = new MemberDao();
		HashMap<String, Object> map = (HashMap<String, Object>) dao.getPointQuery(dto);
		dto.setPointInfo(map);
		return true;
	}
    
     public boolean point_dl_list(MemberDTO dto, int curPage) throws Exception {
		MemberDao dao = new MemberDao();
		int total = dao.getDLTotalCount(dto);
		HashMap<String, Integer> pageMap = CommUtil.getPageInfo(curPage, total, 10, 10);
		int skip = pageMap.get("skip");
		List<HashMap<String, Object>> queryResult = dao.getDLList(dto, skip, 10);
		dto.setListDL(queryResult);
		dto.setPageMap(pageMap);
		return true;
	}
     
     public boolean point_info_list(MemberDTO dto, int curPage) throws Exception {
 		MemberDao dao = new MemberDao();
 		int total = dao.getPointInfoTotalCount(dto);
 		HashMap<String, Integer> pageMap = CommUtil.getPageInfo(curPage, total, 10, 10);
 		int skip = pageMap.get("skip");
 		List<HashMap<String, Object>> queryResult = dao.getPointInfoList(dto, skip, 10);
 		dto.setListPointInfo(queryResult);
 		dto.setPageMap(pageMap);
 		return true;
 	}
     
     public String rankNameChange(String name){
    	 if(name == null || (name.equals("0") || name.equals(""))){name = ".";}
    	 else if(name.equals("1")){name = "UR000003";}
    	 else if(name.equals("2")){name = "UR000002";}
    	 else if(name.equals("3")){name = "UR000001";}
    	 else if(name.equals("4")){name = "UR999999";}
    	 return name;
     }
    
}
